﻿using System;
using System.Collections.Generic;
using System.Text;

namespace AlgorithmDemo
{
    public class Fibonacci
    {
        private const int N = 10000;
        public static ulong[] fArr = new ulong[N];

        /// <summary>
        /// 递归
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public static int f(int n)
        {
            if (n == 1 || n == 2)
                return 1;
            else
                return f(n - 1) + f(n - 2);
        }

        public static ulong foi(int n)
        {
            fArr[0] = 1;
            fArr[1] = 1;

            for (int i = 2; i <n; i++)
            {
                fArr[i] = fArr[i - 1] + fArr[i - 2];
            }

            return fArr[n];

        }

        public static void ToString()
        {
            foreach(var t in fArr)
            {
                if (t == 0)
                    break;
                Console.WriteLine(t);
            }
        }
    }
}
